<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>
<style>
a.active
{
	color:blue;
}
a.inactive
{
	color:gray;
}

</style>
<script type="text/javascript">
$(function(){
	$("a.add_home").click(function()
		{   
			$.getJSON("/<?=$sess->viewLang?>/admin/ajax/widget-weight",
				{
					content_id: $(this).attr('name'),
					content_module: 'event',
					widget_identifier: 'home',
					operation: 'insert'
				}, 
                function(json){
                	console.log(json);
                    if(json.success)
                    {
                    	alert('Added');
                    	$(this).addClass('inactive');
                    	$(".remove_home[name=" + $(this).attr('name') + "]").addClass('active');
                    }
                    else
                    	alert(json.errorMessage);
             })
     });
     
     $("a.remove_home").click(function()
		{   
			$.getJSON("/<?=$sess->viewLang?>/admin/ajax/widget-weight",
				{
					content_id: $(this).attr('name'),
					content_module: 'event',
					widget_identifier: 'home',
					operation: 'delete'
				}, 
                function(json){
                    if(json.success)
                    	alert('success');
                    else
                    	alert(json.errorMessage);
             })
     });
});
</script>

<div class="box white_bg">

<?foreach ($this->viewParams['displayData'] as $k => $v) :?>
	<?=$v['title'];?>
	<a href="javascript:void();" name="<?=$v['id']?>" class="add_home" > Add</a>
	 | <a href="javascript:void();" name="<?=$v['id']?>" class="remove_home" > Remove</a>
	<br/>
<?endforeach?>

</div>